package com.yc.backoffice.web.controller;

import com.yc.backoffice.model.Items;
import com.yc.backoffice.service.IItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("items")
public class ItemsController {
    @Autowired
    private IItemsService itemsService;
    @RequestMapping("list")
    public String list(){
        System.out.println(itemsService);
        List<Items> list=itemsService.findAll();
        for(Items item:list){
            System.out.println(item.getName()+":"+item.getPrice());
        }
        return "user/list";

    }
    @RequestMapping("save")
    public  String save(){
        Items items=new Items();
        items.setName("uuid");
        items.setPrice(800.08F);
        items.setDetail("uuid2");
        items.setCreatetime(new Date());
        itemsService.saveOrUpdate(items);
        return "items/list";
    }



}
